var app = getApp();
Page( Object.assign({},{
    data:{
        info:'',
        allwork : [],
        color : '',
        workinfo : {},
        allerr : 0,
        rightnum : 0,
        current : 1,
		siteroot : app.siteInfo.siteroot.replace('app/index.php', ''),uniacid: app.siteInfo.uniacid,
    },

    onLoad:function(options){
        var self = this;
        var wid = options.wid ? options.wid : '';

        self.setData({
            options : options,
            wid : wid,
        })

        app.com.http('study','POST',{op:'errlog',wid:wid},0,false,'','',function(res){
            if (!res.data.errno && res.data) {

                var color = app.com.mainColor(res.data.data.params.style);

                self.setData({
                    info : res.data.data.info,
                    color : color,
                    params : res.data.data.params,
                    workinfo : res.data.data.workinfo,
                    allerr : res.data.data.allerr,
                    rightarra : res.data.data.rightarra,
                    all : 0,
                },function(){
                    self.setData({
                        inited : true,
                    });
                });

                wx.setNavigationBarTitle({
                    title: '错题汇总'
                });

            }else{
                app.com.alert(res.data.message);
            }
        });
    },
    onPullDownRefresh: function () {
        if( this.data.isdown || this.data.isend ) return false;
        this.onLoad( this.data.options );
        this.setData({
            isdown : false,
        });
        wx.stopPullDownRefresh();
    },
    next(){
        var self = this;
        app.com.http('study','POST',{op:'errlog',wid:this.data.wid},0,true,'','',function(res){
            if (!res.data.errno && res.data) {
                self.setData({
                    workinfo : res.data.data.workinfo,
                    rightarra : res.data.data.rightarra,
                    current : self.data.current+1,
                });
            }else{
                app.com.alert(res.data.message);
            }
        });
    },
    back(){
        wx.navigateBack();
    },
    location : function( e ){
        app.com.location( e );
    },
    otherapp : function( e ){
        app.com.otherapp( e );
    },
    navigateto : function( e ){
        app.com.navigateto( e);
    },
    redirectto : function( e ){
        app.com.redirectto( e );
    },    
    callphone : function(e){
        app.com.callphone( e );
    },
    showimages : function( e ){
        app.com.showimages( e );
    },
    footNavigate(e){
        var url = e.currentTarget.dataset.url;
        wx.switchTab({
          url: url
        })
    },
    
}))